package com.young.weixin.configure;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 微信配置参数
 *
 * @author wangjiyu
 * @date 2021/10/5 12:32
 */
@Configuration
@ConfigurationProperties("young.weixin")
public class WxConfigure {
    /**
     * appId
     */
    private String appid;
    /**
     * secret
     */
    private String secret;
    /**
     * 微信服务器配置里的token
     */
    private String token;
    /**
     * 消息加解密密钥
     */
    private String encodingAESKey;
    /**
     * 获取access_token的url
     */
    private String accessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";

    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getEncodingAESKey() {
        return encodingAESKey;
    }

    public void setEncodingAESKey(String encodingAESKey) {
        this.encodingAESKey = encodingAESKey;
    }

    public String getAccessTokenUrl() {
        return String.format(accessTokenUrl, appid, secret);
    }

    public void setAccessTokenUrl(String accessTokenUrl) {
        this.accessTokenUrl = accessTokenUrl;
    }
}
